<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="renderer" content="webkit" />
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>{:get_system_config('web','admin_title')}</title>	
    <link rel="stylesheet" href="{__CSS__}/student.css" />
</head>

<body>
	<div id="container">
		<div class="login">
			<img src="{__IMG__}/login_img.jpg" class="login-img">
			<div class="right-wrap">
				<div class="login-logo"><a href="/"><img src="{__IMG__}/login_logo.png"></a></div>
				<div class="login-wrap">
					<div class="login-way">
						<span class="active">帐号登录</span>
					</div>
					<div class="account-login">
						<div class="form-box">
							<form id="gouguLogin" class="layui-form">
								<div class="form-item">
									<input type="text" name="name" placeholder="账户" autocomplete="off" class="login-input">
								</div>
								<div class="form-item">
									<input type="password" name="password" placeholder="密码" autocomplete="off" class="login-input">
								</div>
								<div class="form-item">
									<div style="width:140px;display:inline-block;">
										<input type="text" name="captcha" placeholder="验证码" autocomplete="off" class="login-input" style="width: 140px;">
									</div>
									<div class="captcha-img">
										{:captcha_img()}
										<input type="hidden" value="{:make_token()}" />
									</div>
								</div>
								<div class="form-item">
									<button id="loginSubmit" type="button" class="login-btn">登录</button>
								</div>
							</form>
							<div class="footer-operation">
								<p><a>忘记密码？</a></p>
								<p>还没有帐号？<a href="/home/login/reg">立即注册</a></p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="foot">
			{:get_system_config('web','copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
				rel="nofollow" style="margin-left: 12px;color:#458BF3">{:get_system_config('web','icp')}</a>，Powered by GouguCMS
		</div>
	</div>

<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post"
      class='form-horizontal layui-form' style='padding-top:20px'>
    <input type="hidden" name="id" value="{:input('id')}"/>
    <div class="form-group">
        <label class="col-sm-2 control-label">期刊</label>
        <div class='col-sm-3'>
            <select name="magazine" placeholder="请选择期刊" lay-filter="magazine">
            <option value="">请检索关键词或选择</option>
            {volist name="$magazines" }
            <option value="{$magazine.id}">{$magazine.name}
            </option>
            {/volist}
            </select>
        </div>
        <div class="col-sm-3">
            <select name="publish" id="publish">
                <option value=""></option>
            </select>
        </div>
    </div>


    <div class="hr-line-dashed"></div>
    <div class="col-sm-8 col-sm-offset-2">
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">提交数据</button>
        </div>
    </div>
</form>

	<script language="javascript" src="{__JS__}/jquery.min.js"></script>
	<script language="javascript" src="{__JS__}/layer/layer.js"></script>
	<script>
    layui.use('form', function(){
        var form = layui.form;
        form.on('select(magazine)', function(data){
            var areaId=data.elem.value;
            $.ajax({
                type: 'POST',
                url: "{:url('getPublish')}",
                data: {areaId:areaId},
                dataType:  'json',
                success:function(e){
                    console.log(e.data);
                    //empty() 方法从被选元素移除所有内容
                    $("select[name='publish']").empty();
                    var html = "<option value='0'>选择期数</option>";
                    $(e.data).each(function (v, k) {
                        html += "<option value='" + k.id + "'>" + k.title + "</option>";
                    });
                    //把遍历的数据放到select表里面
                    $("select[name='publish']").append(html);
                    //从新刷新了一下下拉框
                    form.render('select');      //重新渲染
                }
            });
        });

    });
</script>
	<script type="text/javascript">
		$('#loginSubmit').on('click', function () {
			$.ajax({
				url: "/home/login/login_submit",
				data: $('#gouguLogin').serialize(),
				type: 'post',
				async: false,
				success: function (res) {
					layer.msg(res.msg);
					if (res.code === 0) {
						setTimeout(function () {
							window.location.href="{:url('/home/user/index')}";
						}, 1500);
					} else {
						$('[alt="captcha"]').click();
					}
				}
			})
		});
	</script>
</body>

</html>